home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / comms / www / httpresume / rexx / suffixdownload.rexx < prev    next >
OS/2 REXX Batch file  |  1999-04-28  |  1KB  |  48 lines

  1. /* $VER: SuffixDownload.rexx 1.0 (28.12.98)       */
  2. /* by Andrija Antonijevic <TheAntony@bigfoot.com> */
  3. /* Downloads file and appends suffix to its name  */
  4. /* until it's completely downloaded. After that,  */
  5. /* it restores the original name.                 */
  6. /*                                                */
  7. /* Start this script when you would otherwise     */
  8. /* click on "Start" to download a file.           */
  9.  
  10. OPTIONS RESULTS
  11.  
  12. Suffix = '.resuming'
  13. SuffixLen = LENGTH(Suffix)
  14.  
  15. IF ~SHOW('L', 'rexxsupport.library') THEN IF ~ADDLIB('rexxsupport.library', 0, -30, 0) THEN DO 
  16.     SAY "Couldn't open rexxsupport.library!"
  17.     EXIT 10
  18. END
  19.  
  20. HPort = ADDRESS()
  21. IF (LEFT(HPort, 11) ~= 'HTTPRESUME.') THEN DO
  22.     SAY 'This has to be started from HTTPResume!'
  23.     EXIT 20
  24. END
  25.  
  26. QUERY OUTFILE
  27. File = RESULT
  28. QUERY URL
  29. What = RESULT
  30.  
  31. /* Strip suffix from filename */
  32.  
  33. IF RIGHT(File, SuffixLen) = Suffix THEN File = LEFT(File, LENGTH(File) - SuffixLen)
  34.  
  35. SET OUTFILE File || Suffix
  36. SET URL What
  37. START
  38. Working = 1
  39. DO WHILE Working > 0
  40.     CALL Delay(150)        /* Pause 3 seconds */
  41.     QUERY FINISHED
  42.     Working = RESULT
  43. END
  44.  
  45. IF Working = 0 THEN DO    /* Downloading finished, no errors */
  46.     ADDRESS COMMAND 'C:Rename FROM ' || File || Suffix || ' TO ' || File ' QUIET'
  47. END
  48.